package com.example.mapp;

import com.example.entity.training.TrainingPlanExt;
import com.example.entity.training.TrainingPlan;
import com.example.mapp.buildSql.TrainingPlanMappSql;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface TrainingPlanMapp {

    @Insert(" insert into training_plan (check_in_table, end_date, materials, lead_unit_id, lead_unit_name, plan_content, plan_name, plan_type, start_date, summary_statement, test_paper, user_name, create_date, create_user) VALUES " +
            "(#{checkInTable},#{endDate},#{materials},#{leadUnitId},#{leadUnitName},#{planContent},#{planName},#{planType},#{startDate},#{summaryStatement},#{testPaper},#{userName},#{createDate},#{createUser})")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id",before = false,resultType = Long.class)
    int insert(TrainingPlan trainingPlan) throws Exception;

    @Delete("delete from training_plan where id=#{id}")
    int delete(String id) throws  Exception;

    @Update("update training_plan set end_date=#{endDate},plan_content=#{planContent},plan_name=#{planName},plan_type=#{planType},start_date=#{startDate},user_name=#{userName} where id=#{id}")
    int update(Map trainingPlan) throws Exception;

    @SelectProvider(type = TrainingPlanMappSql.class,method = "queryTrainingPlan")
    List<TrainingPlan> query(TrainingPlan trainingPlan) throws Exception;

    @SelectProvider(type = TrainingPlanMappSql.class, method = "queryUnitAndUser")
    List<TrainingPlanExt> queryPartyAndUser(TrainingPlan trainingPlan) throws Exception;

    @Update(" update training_plan set "
            + " materials=#{materials} where id=#{id} ")
    int uploadMaterials(TrainingPlan trainingPlan) throws Exception;

    @Update(" update training_plan set "
            + " check_in_table=#{checkInTable} where id=#{id} ")
    int uploadCheckInTable(TrainingPlan trainingPlan) throws Exception;

    @Update(" update training_plan set "
            + " test_paper=#{testPaper} where id=#{id} ")
    int uploadTestPaper(TrainingPlan trainingPlan) throws Exception;

    @Update(" update training_plan set "
            + " summary_statement=#{summaryStatement} where id=#{id} ")
    int uploadSummaryStatement(TrainingPlan trainingPlan) throws Exception;

}
